package com.qf.servlet;

import com.qf.pojo.User;
import com.qf.service.UserService;
import com.qf.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author AzureSky_X
 * @Date 2021/1/13 20:14
 * @Version 1.0
 */
@WebServlet("/showUserUpdateUI")
public class showUserUpdateUI extends HttpServlet {

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        String idStr = request.getParameter("id");
//        Integer id = Integer.valueOf(idStr);
        //将String格式的id转化成int格式
        Integer id=Integer.valueOf(request.getParameter("id"));

        UserService userService=new UserServiceImpl();
        //根据用户id查询信息
        User user01 = userService.selectUserById(id);

        //把查询到的信息存入request
        request.setAttribute("user01",user01);
        request.getRequestDispatcher("/updateUser.jsp").forward(request,response);


    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}